<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:f="http://java.sun.com/jsf/core" 
  xmlns:p="http://primefaces.org/ui" 
  xmlns:h="http://java.sun.com/jsf/html" 
  xmlns:pr="http://java.sun.com/jsf/composite/totororo"
  template="../template_front.xhtml">
  <ui:define name="content">
 	<h1><h:outputText value="#{strings['commandes.YourOrders']}"/></h1>
 	<p:dataTable id="orderTable" value="#{orderController.orders}" var="order">
       <p:column>	
           <f:facet name="header" >
               <h:outputText value="N°"/>
           </f:facet>   	       
		  <h:outputText value="#{strings['commandes.Commande']} n° #{order.id}"/>
       </p:column>       
       <p:column>
           <f:facet name="header" >
               <h:outputText value="#{strings['commandes.DetailOrder']}"/>
           </f:facet>
           <h:outputText value='#{order.items["0"].book.title}' style="margin-left:10px" /> 
           <h:outputText value='- #{order.items["0"].book.price} €, ' style="margin-left:10px" /> 
           
           <h:outputText escape="true" value='#{order.items["1"].book.title}' rendered='#{order.items["1"].book.title != null}' />
           <h:outputText value=' - #{order.items["1"].book.price} €, ' rendered='#{order.items["1"].book.title != null}' />
           
           <h:outputText styleClass="line-beak" value='#{order.items["2"].book.title}' rendered='#{order.items["2"].book.title != null}' />
           <h:outputText value=' - #{order.items["2"].book.price} €, ' rendered='#{order.items["2"].book.title != null}' />
           
           <h:outputText  styleClass="line-beak" value='...' rendered='#{order.items["3"].book.title != null}' />
          
       </p:column>      
       <p:column>	
           <f:facet name="header" >
               <h:outputText value="#{strings['commandes.Date']}"/>
           </f:facet>   	  
           <h:outputText value="#{order.date}" />     
       </p:column>
       
       <p:column>	
           <f:facet name="header" >
               <h:outputText value="#{strings['commandes.Total']}"/>
           </f:facet>   	  
           <h:outputText value="#{order.total} €" />     
       </p:column>
       <!-- Paiement -->
       <p:column >	
           <f:facet name="header" >
               <h:outputText value="#{strings['commandes.Statut']}"/>
           </f:facet>   	  
     
     		<h:form>
	      		<h:commandLink action="#{paiementController.pagePaiement}" rendered="#{order.statutPaiement == 0}">
	      			<h:outputText value="#{strings['commandes.TobePaid']}"/>
	      			<f:param name="orderId" value="#{order.id}"/>
	      		</h:commandLink>
	      		<h:outputText value="#{strings['commandes.Valide']}" rendered="#{order.statutPaiement == 1}"/>
			</h:form>
			
       </p:column>
       <!--  -->
  </p:dataTable>      
   
  <h:form>
	   <h:commandLink >  
	       <h:outputText value="#{strings['commandes.ExportPDF']}" />  
	       <p:dataExporter type="pdf" target=":orderTable" fileName="commandes_facture"/>  
	   </h:commandLink>
   </h:form> 
  </ui:define>
</ui:composition>
